package com.ruoyi.swla2.controller;

import cn.hutool.core.util.CoordinateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.swla2.domain.PressureConfiguration;
import com.ruoyi.swla2.domain.Terminals;
import com.ruoyi.swla2.model.ZoneJoinModel;
import com.ruoyi.swla2.service.IPressureConfigurationService;
import com.ruoyi.swla2.service.ITerminalsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
* @Description: 多表压差配置Controller
* @date: 2025/2/26 14:23
* @author: zt
*/
@RestController
@RequestMapping("/pressureConfiguration")
public class PressureConfigurationController extends BaseController {
    @Autowired
    private IPressureConfigurationService pcService;

    /**
     * 查询列表
     */
    @GetMapping("/list")
    public AjaxResult list(PressureConfiguration configuration) {
        String tenantId = getTenantId();
        List<PressureConfiguration> list = pcService.list(new LambdaQueryWrapper<PressureConfiguration>().eq(PressureConfiguration::getTenantId, tenantId));
        return success(list);
    }

    /**
     * 新增
     */
    @Log(title = "新增多表压差配置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody PressureConfiguration configuration) {
        configuration.setTenantId(this.getTenantId());
        return toAjax(pcService.save(configuration));
    }

    /**
     * 删除
     */
    @Log(title = "删除多表压差配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(pcService.removeBatchByIds(Arrays.asList(ids)));
    }
}
